package com.heimachefu.module.resource.controller;

import com.heimachefu.module.resource.service.ResourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author liuxingdong@heimachefu.com
 * @date 2019/7/19 16:24
 */
@Controller
@RequestMapping("/resource")
public class ResourceController {



    private final ResourceService resourceService;

    @Autowired
    public ResourceController(ResourceService resourceService) {
        this.resourceService = resourceService;
    }



    @GetMapping("/list")
    public ModelAndView list(){
        ModelAndView view = new ModelAndView();
        return view;
    }

    /**
     * 获取资源集合信息
     * @param pageNo
     * @param pageSize
     * @return
     */
    @GetMapping("/page")
    public ModelAndView page(@RequestParam(defaultValue = "0",name = "pageNo")Integer pageNo,
                             @RequestParam(name = "pageSize",defaultValue = "10") Integer pageSize){
        ModelAndView view = new ModelAndView("app/resource/resource_list");
        view.addObject("resourceList",resourceService.list(pageNo,pageSize));
        return view;
    }


}
